//
//  WYCSeeBillController.m
//  初试
//
//  Created by 中企互联 on 2017/10/16.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCSeeBillController.h"
#import "WYCTranslationController.h"
#import "WYCHistoryController.h"
#import "WYCPlanController.h"
#import "WYCSeeBillModel.h"
#import "WYCIntelligentMoneyController.h"
#import "PopViewController.h"
#import "OYRPopOption.h"
#import "WYCHandBillController.h"
#import "WYCBillController.h"
#import "WYCFastCspController.h"

@interface WYCSeeBillController ()<UIScrollViewDelegate>
{
    NSString * codeStr;
}

/** 遮盖View*/
@property(nonatomic,strong)UIView * coverView;

/** view*/
@property(nonatomic,strong)UIView * backView;
@property(nonatomic,strong)    UILabel * typelabel;

/** 标签栏底部的红色指示器 */
@property (nonatomic, weak) UIView  * indicatorView;
/** 底部所有的标签 */
@property (nonatomic, weak) UIView  * titlesView;


/** 数组*/
@property (nonatomic, weak) NSArray  * titlesArray;


/** 模型赋值*/
@property(nonatomic,strong)WYCSeeBillModel * seeBillModel;

/** 底部所有的内容 */
@property (nonatomic, weak) UIScrollView  * contenView;

/** 取反 */
@property (nonatomic, weak) UIButton  * selectedButton;

/** 取输入框 */
@property (nonatomic, weak)UITextField * texField;

/** 遮罩*/
@property(nonatomic,strong)UIView * ejectView;

/** 删除按钮*/
@property(nonatomic,strong) UIButton * buttonsender;

/** 取反 */
@property (nonatomic, strong) UIButton  * xuanzhongButton;

/** 显示View*/
@property(nonatomic,strong)UIView * showView;



@end

@implementation WYCSeeBillController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //Nav
    [self setupNav];
    
    
    
    //请求
    [self setupRequster];
    
    
    
    
    //初始化子控制器
    [self setupChildVces];
    
    
    //底部的scrollview
    [self setupScrollView];
    
   [self setupVersion];
    [self loadversion];
    
   
}
- (void)setupVersion{
    
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    
    // 获取App的版本号
    NSString *appVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
    WYCLog(@"=======%@",appVersion);
    
    NSString * iosVersion = [NSString stringWithFormat:@"%@%@",iosfunction,appVersion];
    [HttpTool POST:iosVersion params:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        WYCLog(@"--------%@",responseObject);
        if ([[responseObject objectForKey:@"code"] intValue] == 0) {
            codeStr = [responseObject objectForKey:@"result"];
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}

#pragma make -------->>请求数据
- (void)setupRequster{
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    params[@"cardId"] = self.cardId;
    params[@"token"] = [WYCAccountTool unarchivetoken];
    
    [HttpTool POST:creditcarddetails params:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"] intValue] == 0) {
            NSDictionary * dict = responseObject[@"result"];
            self.seeBillModel = [WYCSeeBillModel mj_objectWithKeyValues:dict];
        }else{
            
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
            [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
            [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
            [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
        }
        
        //界面
        [self setupCreat];
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
}
//底部还款
- (void)setupbottomView{
    //底部view
    UIView * bottomView = [[UIView alloc] init];
    bottomView.frame = CGRectMake(0, ScreenHeight - 160 * px, ScreenWidth, 160 * px);
    bottomView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bottomView];
    
    
    
    
    
    //标记已还金额
    UIButton * alreadylabel = [[UIButton alloc] init];
    alreadylabel.frame = CGRectMake(0, 0, bottomView.width / 2, 160 * px);
    alreadylabel.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [alreadylabel setTitle:@"快速消费" forState:UIControlStateNormal];
    [alreadylabel setTitleColor:wycMain forState:UIControlStateNormal];
    [alreadylabel addTarget:self action:@selector(alreadylabelClick) forControlEvents:UIControlEventTouchUpInside];
    alreadylabel.titleLabel.font = [UIFont systemFontOfSize:BigFont];
    [bottomView addSubview:alreadylabel];
    
    
    //标记已还清
    UIButton * payofflabel = [[UIButton alloc] init];
    payofflabel.frame = CGRectMake(bottomView.width / 2, alreadylabel.y, alreadylabel.width, alreadylabel.height);
    payofflabel.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [payofflabel setTitle:@"智能还款" forState:UIControlStateNormal];
    payofflabel.backgroundColor = wycMain;
    [payofflabel addTarget:self action:@selector(payofflabelClick) forControlEvents:UIControlEventTouchUpInside];
    [payofflabel setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    payofflabel.titleLabel.font = [UIFont systemFontOfSize:BigFont];
    [bottomView addSubview:payofflabel];
    
    
    
    
}
/**
 *底部的scrollview
 */
- (void)setupScrollView
{
    //不自动调整inset
    self.automaticallyAdjustsScrollViewInsets = NO;
    UIScrollView * contenView = [[UIScrollView alloc]init];
    contenView.frame = self.view.bounds;
    contenView.delegate = self;
    contenView.pagingEnabled = YES;
    
    [self.view insertSubview:contenView atIndex:0];
    contenView.contentSize = CGSizeMake(contenView.width * self.childViewControllers.count,0 );
    
    self.contenView = contenView;
    //
    //    //添加第一个控制器view
    [self scrollViewDidEndScrollingAnimation:contenView];
}


//初始化子控制器
- (void)setupChildVces{
    WYCTranslationController * Translation = [[WYCTranslationController alloc] init];
    Translation.cardId = self.cardId;
    Translation.title = @"账单明细";
    
    [self addChildViewController:Translation];
    
    WYCHistoryController * History = [[WYCHistoryController alloc] init];
    History.cardId = self.cardId;
    History.title = @"还款记录";
    
    [self addChildViewController:History];
    
    WYCPlanController * Plan = [[WYCPlanController alloc] init];
    Plan.title = @"智能还款计划";
    Plan.cardId = self.cardId;
    [self addChildViewController:Plan];
    
}
//界面
- (void)setupCreat{
    
    UIImageView * backView = [[UIImageView alloc] init];
    backView.frame = CGRectMake(0, NavHeight, ScreenWidth, 760 * px);
    backView.image =[UIImage imageNamed:@"backbg"];
    [self.view addSubview:backView];
    
    
    
    UIView * bigView = [[UIView alloc] init];
    bigView.frame = CGRectMake(60 * px, 60 * px, ScreenWidth - 120 * px, 620 * px);
    bigView.backgroundColor = [UIColor whiteColor];
    bigView.layer.cornerRadius = 30 * px;
    [backView addSubview:bigView];
    
    
    UIView * titleView = [[UIView alloc] init];
    titleView.frame = CGRectMake(0, 0, bigView.width, bigView.height / 4);
    titleView.backgroundColor = WYCMain;
    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:titleView.layer.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30 * px, 30 * px)];
    CAShapeLayer * maskLayer = [CAShapeLayer new];
    maskLayer.frame = titleView.bounds;
    maskLayer.path = maskPath.CGPath;
    titleView.layer.mask = maskLayer;
//    titleView.layer.cornerRadius = 30 * px;
    [bigView addSubview:titleView];

    
    UILabel *titleStr = [[UILabel alloc] init];
    titleStr.frame = CGRectMake(40 * px, 60 * px, titleView.width, 60 * px);
    titleStr.text =  [NSString stringWithFormat:@"%@(%@)",self.bankName,self.lastNumber];
    titleStr.textAlignment = NSTextAlignmentLeft;
    titleStr.textColor = [UIColor whiteColor];
    titleStr.font = [UIFont systemFontOfSize:MiddleFont];
    [titleView addSubview:titleStr];
    
    UILabel *benqizhangdan = [[UILabel alloc] init];
    benqizhangdan.frame = CGRectMake(40 * px, CGRectGetMaxY(titleView.frame) + 40 * px, backView.width, 50 * px);
    benqizhangdan.text = @"本期应还";
    benqizhangdan.textAlignment = NSTextAlignmentLeft;
    benqizhangdan.textColor = [UIColor grayColor];
    benqizhangdan.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:benqizhangdan];
    
    UILabel * balancelabel = [[UILabel alloc] init];
    balancelabel.frame = CGRectMake(10,benqizhangdan.frame.size.height+benqizhangdan.frame.origin.y+10 , 600  * px, 70 * px);
    NSString * billAmount = [NSString stringWithFormat:@"%.2f",[self.billAmount doubleValue]];
    balancelabel.text = billAmount;
    balancelabel.textColor = WYCMain;
    balancelabel.textAlignment = NSTextAlignmentLeft;
    balancelabel.font = [UIFont systemFontOfSize:25];
    [bigView addSubview:balancelabel];

    
    UIView  *lineV =[[UIView alloc]init];
    lineV.backgroundColor = WYZGrayBg;
    lineV.frame = CGRectMake(0, CGRectGetMaxY(balancelabel.frame) + 80 * px, bigView.width, 1);
    [bigView addSubview:lineV];
    
    self.typelabel = [[UILabel alloc] init];
     self.typelabel.frame = CGRectMake(ScreenWidth-160, balancelabel.y, 100, 20);
    self.typelabel.textColor = [UIColor whiteColor];
    self.typelabel.layer.masksToBounds = YES;
    self.typelabel.textAlignment = NSTextAlignmentCenter;
    self.typelabel.layer.cornerRadius = 10;
    self.typelabel.font = [UIFont systemFontOfSize:SmallFont];
    [backView addSubview:self.typelabel];
    if ([self.bankType  isEqualToString:@"0"]){
        
        self.typelabel.text = @"";
    } else if ([self.bankType  isEqualToString:@"1"]){
        NSString * aooroveStr = [NSString stringWithFormat:@"待还款"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = WYCMain;
    }else if ([self.bankType  isEqualToString:@"2"]){
        NSString * aooroveStr = [NSString stringWithFormat:@"已还清"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = [UIColor greenColor];
    }else if ([self.bankType  isEqualToString:@"3"]){
        NSString * aooroveStr = [NSString stringWithFormat:@"智能还款中"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = wycBlue;
    }else{
        NSString * aooroveStr = [NSString stringWithFormat:@"智能还款中止"];
        self.typelabel.text = aooroveStr;
        self.typelabel.backgroundColor = WYCMain;
        
    }



    //账单日
    UILabel *Statementlabel = [[UILabel alloc] init];
    Statementlabel.frame = CGRectMake(0, CGRectGetMaxY(lineV.frame) + 20 * px, bigView.width / 4, 50 * px);
    Statementlabel.text = @"账单日";
    Statementlabel.textAlignment = NSTextAlignmentCenter;
    Statementlabel.textColor = [UIColor grayColor];
    Statementlabel.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Statementlabel];


    UILabel *Statement = [[UILabel alloc] init];
    Statement.frame = CGRectMake(Statementlabel.x, CGRectGetMaxY(Statementlabel.frame) + 20 * px, Statementlabel.width, Statementlabel.height);
    Statement.text = [NSString stringWithFormat:@"%@",self.billDate];
    Statement.textAlignment = NSTextAlignmentCenter;
    Statement.textColor = [UIColor blackColor];
    Statement.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Statement];

    //还款日
    UILabel *Repaymentlabel = [[UILabel alloc] init];
    Repaymentlabel.frame = CGRectMake(bigView.width / 4, Statementlabel.y, Statementlabel.width, Statementlabel.height);
    Repaymentlabel.text = @"还款日";
    Repaymentlabel.textAlignment = NSTextAlignmentCenter;
    Repaymentlabel.textColor = [UIColor grayColor];
    Repaymentlabel.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Repaymentlabel];


    UILabel *Repayment = [[UILabel alloc] init];
    Repayment.frame = CGRectMake(Repaymentlabel.x, CGRectGetMaxY(Repaymentlabel.frame) + 20 * px, Statementlabel.width, Statementlabel.height);
    NSString * dueDate = [NSString stringWithFormat:@"%@",self.dueDate];
    Repayment.text = dueDate;
    Repayment.textColor = [UIColor blackColor];
    Repayment.textAlignment = NSTextAlignmentCenter;
    Repayment.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Repayment];


    //免息期
    UILabel *Gracelabel = [[UILabel alloc] init];
    Gracelabel.frame = CGRectMake(bigView.width / 2, Statementlabel.y, Statementlabel.width, Statementlabel.height);
    Gracelabel.text = @"免息期";
    Gracelabel.textAlignment = NSTextAlignmentCenter;
    Gracelabel.textColor = [UIColor grayColor];
    Gracelabel.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Gracelabel];
    
    
    UILabel *Grace = [[UILabel alloc] init];
    Grace.frame = CGRectMake(Gracelabel.x, CGRectGetMaxY(Gracelabel.frame) + 20 * px, Statementlabel.width, Statementlabel.height);
    NSString * gracePeriod = [NSString stringWithFormat:@"%@",self.gracePeriod];
    Grace.text = gracePeriod;
    Grace.textColor = [UIColor blackColor];
    Grace.textAlignment = NSTextAlignmentCenter;
    Grace.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Grace];



    //总额度
    UILabel *Totallabel = [[UILabel alloc] init];
    Totallabel.frame = CGRectMake(bigView.width / 4 * 3, Statementlabel.y, Statementlabel.width, Statementlabel.height);
    Totallabel.text = @"总额度";
    Totallabel.textAlignment = NSTextAlignmentCenter;
    Totallabel.textColor = [UIColor grayColor];
    Totallabel.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Totallabel];


    UILabel *Total = [[UILabel alloc] init];
    Total.frame = CGRectMake(Totallabel.x, CGRectGetMaxY(Totallabel.frame) + 20 * px, Statementlabel.width, Statementlabel.height);
    Total.textAlignment = NSTextAlignmentCenter;
    NSString * creditLine = [NSString stringWithFormat:@"%.2f",[self.creditLine doubleValue]];
    Total.text = creditLine;
    Total.textColor = [UIColor blackColor];
    Total.font = [UIFont systemFontOfSize:SmallFont];
    [bigView addSubview:Total];


   



    UIView *titlesView = [[UIView alloc] init];
    titlesView.backgroundColor = [UIColor whiteColor];
    titlesView.frame =CGRectMake(0, CGRectGetMaxY(backView.frame), ScreenWidth, WYCTitilesViewH);
    titlesView.backgroundColor = [UIColor whiteColor];//设置阴影的透明度
    [self.view addSubview:titlesView];
    self.titlesView = titlesView;
    
    NSArray * titlearray = @[@"账单明细",@"还款记录",@"消费计划"];
    CGFloat width = ScreenWidth / 3;
    CGFloat height = 100 * px;
    
    for (NSInteger i = 0; i < titlearray.count; i++) {
        UIButton *button = [[UIButton alloc] init];
        button.tag = i;
        button.height = height;
        button.width = width;
        button.x = ScreenWidth / 3 * i;
        button.y = 50 * px;
        [button setTitle:titlearray[i] forState:UIControlStateNormal];
        [button layoutIfNeeded];//强制布局
        button.titleLabel.textAlignment = NSTextAlignmentCenter;
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setTitleColor:wycMain forState:UIControlStateDisabled];
        button.titleLabel.font = [UIFont systemFontOfSize:48*px];
        [button addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];
        [titlesView addSubview:button];
        
        if (i == 0) {
            [self titleClick:button];
            
            button.enabled = NO;
            
            self.selectedButton = button;
            
            // 让按钮内部的label根据文字内容来计算尺寸
            self.indicatorView.width = 108*px;
            self.indicatorView.centerX = button.centerX ;
        }
    }
    //     [titlesView addSubview:indicatorView];
    
    
}
- (void)titleClick:(UIButton *)button
{
    //修改按钮状态
    self.selectedButton.enabled = YES;
    button.enabled = NO;
    self.selectedButton = button;
    // 动画
    [UIView animateWithDuration:0.25 animations:^{
        self.indicatorView.width = 108*px;
        self.indicatorView.centerX = button.centerX;
    }];
    //滚动
    CGPoint offset = self.contenView.contentOffset;
    offset.x = button.tag * self.contenView.width;
    [self.contenView setContentOffset:offset animated:YES];
}
#pragma mark - <UIScrollViewDelegate>
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
    
    //当前的索引
    //长度NSInteger * interger;
    int index = scrollView.contentOffset.x / scrollView.width;
    
    //取出子控制器
    UITableViewController * vc = self.childViewControllers[index];
    vc.tableView.x = scrollView.contentOffset.x;
    
    if (ScreenHeight == 812) {
        vc.tableView.y = 1000 * px;//tableview的高度默认为20
        vc.tableView.height = scrollView.height - 1000 * px;//tableview的底部

    }
    else
    {
        vc.tableView.y = 930 * px;//tableview的高度默认为20
        vc.tableView.height = scrollView.height - 930 * px;//tableview的底部

    }
    vc.tableView.width = ScreenWidth;

    [scrollView addSubview:vc.view];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    //点击按钮
    int index = scrollView.contentOffset.x / scrollView.width;
    [self titleClick:self.titlesView.subviews[index]];
    
    
    // 添加子控制器的view
    [self scrollViewDidEndScrollingAnimation:scrollView];
}
- (void)setupNav {
    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
//    NSString * titleStr = [NSString stringWithFormat:@"%@(%@)",self.bankName,self.lastNumber];
    self.navigationItem.title = @"账单管理";
    
    //右侧按钮
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImage:@"Three" hight:@"Three" target:self action:@selector(ThreeClick:)];
}

- (void)ThreeClick:(UIButton *)optionButton{
    
    UIWindow *window = [[UIApplication sharedApplication].delegate window];
    CGRect frame = [optionButton convertRect:optionButton.bounds toView:window];
    
    
    OYRPopOption *s = [[OYRPopOption alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    
    s.option_optionContents = @[@"隐藏该卡", @"手动账单"];
    // 使用链式语法直接展示 无需再写 [s option_show];
    [[s option_setupPopOption:^(NSInteger index, NSString *content) {
        
        
        if (index == 0) {
            self.ejectView = [[UIView alloc] init];
            self.ejectView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
            self.ejectView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
            [[UIApplication sharedApplication].keyWindow  addSubview:self.ejectView];
            
            UIView * showView = [[UIView alloc] init];
            showView.frame = CGRectMake(80 * px, ScreenHeight / 2 - 320 * px, ScreenWidth - 160 * px, 640 * px);
            showView.layer.cornerRadius = 3;
            showView.layer.masksToBounds = YES;
            showView.backgroundColor = [UIColor whiteColor];
            [self.ejectView addSubview:showView];
            self.showView = showView;
            
            UIView * topView = [[UIView alloc] init];
            topView.frame = CGRectMake(0, 0, showView.width, 150 * px);
            topView.backgroundColor = WYCGlobalBg;
            [showView addSubview:topView];
            
            UILabel * showlabel = [[UILabel alloc] init];
            showlabel.frame = CGRectMake(0, 0, topView.width, topView.height);
            showlabel.text = [NSString stringWithFormat:@"删除%@%@",self.bankName,self.lastNumber];
            showlabel.font = [UIFont boldSystemFontOfSize:BigFont];
            showlabel.textAlignment = NSTextAlignmentCenter;
            [topView addSubview:showlabel];
            
            
            
            for (NSInteger i = 0; i < 2; i++) {
                UIButton * button = [[UIButton alloc] init];
                button.tag = i;
                [button setImage:[UIImage imageNamed:@"nomor"] forState:UIControlStateNormal];
                [button setImage:[UIImage imageNamed:@"Select"] forState:UIControlStateDisabled];
                button.frame = CGRectMake(40 * px, 200 * px + (300 / 2 * i * px) , 80 * px, 80 * px);
                [button layoutIfNeeded];//强制布局
                [button addTarget:self action:@selector(deletebuttonclick:) forControlEvents:UIControlEventTouchUpInside];
                [showView addSubview:button];
                self.buttonsender = button;
                
                if (i == 0) {
                    [self deletebuttonclick:button];
                    
                    button.enabled = NO;
                    
                    self.xuanzhongButton = button;
                    
                }
                
                
                UILabel * onelabel = [[UILabel alloc] init];
                onelabel.frame = CGRectMake(CGRectGetMaxX(self.buttonsender.frame) + 20 * px, CGRectGetMaxY(showlabel.frame) + 20 * px, showView.width - 160 * px, 150 * px);
                onelabel.numberOfLines = 0;
                onelabel.textColor = [UIColor grayColor];
                onelabel.text = @"隐藏该卡，重新导不在首页显示，或设置管理卡片中恢复";
                onelabel.font = [UIFont systemFontOfSize:WyzFont];
                [topView addSubview:onelabel];
                
                
                UILabel * towlabel = [[UILabel alloc] init];
                towlabel.frame = CGRectMake(onelabel.x, CGRectGetMaxY(onelabel.frame), onelabel.width, onelabel.height);
                towlabel.numberOfLines = 0;
                towlabel.textColor = [UIColor grayColor];
                towlabel.text = @"删除该卡，如果恢复请重新导入网银，或删除已导入邮箱重新导入";
                towlabel.font = [UIFont systemFontOfSize:WyzFont];
                //                towlabel.textAlignment = NSTextAlignmentCenter;
                [topView addSubview:towlabel];
                
                
                UIButton * mainbutton = [[UIButton alloc] init];
                mainbutton.frame = CGRectMake(0, showView.height - 150 * px, showView.width / 2, 150 * px);
                [mainbutton.layer setBorderColor:[UIColor grayColor].CGColor];
                [mainbutton.layer setBorderWidth:0.5];
                [mainbutton.layer setMasksToBounds:YES];
                [mainbutton setTitle:@"取消" forState:UIControlStateNormal];
                [mainbutton setTitleColor:WYCMain forState:UIControlStateNormal];
                [mainbutton addTarget:self action:@selector(mainbuttonClick) forControlEvents:UIControlEventTouchUpInside];
                mainbutton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
                [showView addSubview:mainbutton];
                
                
                
                UIButton * returebutton = [[UIButton alloc] init];
                returebutton.frame = CGRectMake(CGRectGetMaxX(mainbutton.frame), mainbutton.y, showView.width / 2, 150 * px);
                [returebutton.layer setBorderColor:[UIColor grayColor].CGColor];
                [returebutton.layer setBorderWidth:0.5];
                [returebutton.layer setMasksToBounds:YES];
                [returebutton setTitle:@"确定" forState:UIControlStateNormal];
                [returebutton setTitleColor:WYCMain forState:UIControlStateNormal];
                [returebutton addTarget:self action:@selector(returebuttonClick) forControlEvents:UIControlEventTouchUpInside];
                returebutton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
                [showView addSubview:returebutton];
                
            }
            
        }else{
            
            WYCHandBillController * OperationBll = [[WYCHandBillController alloc] init];
            [self.navigationController pushViewController:OperationBll animated:NO];
            
        }
        
    } whichFrame:frame animate:YES] option_show];
    
}
- (void)mainbuttonClick{
    self.showView.hidden = YES;
    self.ejectView.hidden = YES;
    
}
- (void)returebuttonClick{
    
    
    if(self.xuanzhongButton.tag == 0){
        
        NSMutableDictionary * params = [NSMutableDictionary dictionary];
        params[@"token"] = [WYCAccountTool unarchivetoken];
        params[@"cardId"] = self.cardId;
        params[@"isHideCard"] = @"1";
        [HttpTool POST:creditcardsetHideCard params:params success:^(NSURLSessionDataTask *task, id responseObject) {
            
            if ([[responseObject objectForKey:@"code"] intValue] == 0) {
                
                [self showToast:@"成功"];
                [self mainbuttonClick];
                for (UIViewController *controller in self.navigationController.viewControllers) {
                    if ([controller isKindOfClass:[WYCBillController class]]) {
                        [self.navigationController popToViewController:controller animated:YES];
                        break;
                    }
                }
                WYCBillController *SendDrugVC = [[WYCBillController alloc]init];
                [self.navigationController popToViewController:SendDrugVC animated:YES];
                
            }else{
                
                [self showToast:msgStr];
                
            }
            
        } fail:^(NSURLSessionDataTask *task, NSError *error) {
            
            [self showToast:Failed];
            
        }];
    }else{
        NSMutableDictionary * params = [NSMutableDictionary dictionary];
        params[@"token"] = [WYCAccountTool unarchivetoken];
        params[@"cardId"] = self.cardId;
        [HttpTool POST:creditcardunbindCreditCard params:params success:^(NSURLSessionDataTask *task, id responseObject) {
            
            if ([[responseObject objectForKey:@"code"] intValue] == 0) {
                
                [self showToast:@"成功"];
                [self mainbuttonClick];
                
                for (UIViewController *controller in self.navigationController.viewControllers) {
                    if ([controller isKindOfClass:[WYCBillController class]]) {
                        [self.navigationController popToViewController:controller animated:YES];
                        break;
                    }
                }
                WYCBillController *SendDrugVC = [[WYCBillController alloc]init];
                [self.navigationController popToViewController:SendDrugVC animated:YES];
                
            }else{
                
                [self showToast:msgStr];
                
            }
            
        } fail:^(NSURLSessionDataTask *task, NSError *error) {
            
            [self showToast:Failed];
            
        }];
        
    }
}
- (void)deletebuttonclick:(UIButton *)sender{
    
    
    WYCLogFunc;
    //修改按钮状态
    self.xuanzhongButton.enabled = YES;
    sender.enabled = NO;
    self.xuanzhongButton = sender;
    WYCLog(@"---------%ld",(long)self.xuanzhongButton.tag);
}

#pragma make ---------->>已还清金额
- (void)payofflabelClick{
    WYCIntelligentMoneyController * repay = [[WYCIntelligentMoneyController alloc] init];
        repay.cardId = self.cardId;
    
        //银行卡姓名
        repay.bankName = self.bankName;
    
        //银行卡后四位
        repay.lastNumber = self.lastNumber;
    
        //银行卡多少天出账单
        repay.outbBllDay = self.outbBllDay;
    
        //本期账单金额
        repay.billAmount = self.billAmount;
    
    
        //免息期
        repay.gracePeriod = self.gracePeriod;
    
        repay.bankState = self.bankType;
        //总额度
        repay.creditLine = self.creditLine;
    
    
        //还款日
        repay.dueDate = self.dueDate;
    
    
        //账单日
        repay.billDate = self.billDate;
    
    
    [self.navigationController pushViewController:repay animated:NO];
    
}

#pragma make ---------->>标记已还金额
- (void)alreadylabelClick{
//    [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"努力开发中..."];
//    return;
    WYCFastCspController * Fastcon = [[WYCFastCspController alloc] init];
    [self.navigationController pushViewController:Fastcon animated:NO];
}
- (void)buttonClick:(UIButton *)sender{
    
    if (sender.tag == 11) {
        
        self.texField.text = [NSString stringWithFormat:@""];
    
    }else{
        
        self.texField.text = [NSString stringWithFormat:@"%@%@",self.texField.text,sender.titleLabel.text];
        
    }
    
}
-(void)loadversion
{
    
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    NSString *appVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
    NSLog(@"=======%@",appVersion);
    params[@"version"] = appVersion;
    
    [HttpTool POST:function params:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"] intValue ] == 0) {
            NSLog(@"第一%@",responseObject);
            if ([[responseObject objectForKey:@"result"] intValue ] == 0) {
            }
            else
            {
                [self setupbottomView];

            }
            
        }
        
        
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}
#pragma make ----------->>取消
- (void)DetermineClick{
    self.coverView.hidden = YES;
    self.backView.hidden = YES;
    
    NSMutableDictionary * params = [NSMutableDictionary dictionary];
    params[@"token"] = [WYCAccountTool unarchivetoken];
    params[@"cardId"] = self.cardId;
    params[@"payOff"] = @"2";
    params[@"amount"] = self.texField.text;
    [HttpTool POST:creditcardalreadyRepaid params:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([[responseObject objectForKey:@"code"] intValue] == 0) {
            
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:@"标记成功"];
            [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
            [SVProgressHUD setForegroundColor:[UIColor whiteColor]]; //字体颜色
            [SVProgressHUD setBackgroundColor:[UIColor blackColor]];   //背景颜色
            
        }else{
            
            [SVProgressHUD showImage:[UIImage imageNamed:@""] status:msgStr];
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}

#pragma make ----------->>取消
- (void)cancelClick{
    
    self.coverView.hidden = YES;
    self.backView.hidden = YES;
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    
    self.navigationController.navigationBar.hidden = YES;
    
    
    UIView * NavView = [[UIView alloc] init];
    NavView.frame = CGRectMake(0, 0, ScreenWidth, NavHeight);
    NavView.backgroundColor = WYCMain;
    [self.view addSubview:NavView];
    
    
    
    CALayer *bottomLineLayer = [[CALayer alloc] init];
    bottomLineLayer.frame = CGRectMake(0, NavView.bounds.size.height - 0.5, NavView.bounds.size.width, 0.5);
    bottomLineLayer.backgroundColor = [UIColor redColor].CGColor;
    [NavView.layer addSublayer:bottomLineLayer];
    
    
    //返回按钮
    UIButton *  backbutton = [[UIButton alloc] init];
    [backbutton setImage:[UIImage imageNamed:@"Nav_back"] forState:UIControlStateNormal];
    [backbutton addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
    backbutton.frame = CGRectMake(30 * px, titleY, 66 * px , 66 * px);
    [NavView addSubview:backbutton];
    
    
    //返回按钮
    UIButton *  fanhuibutton = [[UIButton alloc] init];
    [fanhuibutton setImage:[UIImage imageNamed:@"Three"] forState:UIControlStateNormal];
    [fanhuibutton addTarget:self action:@selector(ThreeClick:) forControlEvents:UIControlEventTouchUpInside];
    fanhuibutton.frame = CGRectMake(NavView.width - 96 * px, titleY, 70 * px , 70 * px);
    [NavView addSubview:fanhuibutton];
    
    
    UILabel * NavRigsterLabel = [[UILabel alloc] init];
    NavRigsterLabel.frame = CGRectMake(0, titleY, NavView.width, 68 * px);
    NavRigsterLabel.textColor = [UIColor whiteColor];
    NavRigsterLabel.font = [UIFont boldSystemFontOfSize:BigFont];
    NavRigsterLabel.textAlignment = NSTextAlignmentCenter;
    NavRigsterLabel.text = @"账单管理";
    [NavView addSubview:NavRigsterLabel];
}
- (void)backClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}

@end
